# -*- coding:utf-8 -*-

"""
普通产品推荐

"""
from aw import *
from autotest import *


class Test_004(TestCase):

    # 新人周增：ZC201810231642346085675
    # 新人月增：ZC201810231704586551135
    # 新人双月增：ZC201810231934317207970
    # 新人季增：ZC201810231935012555011

    def setUp(self):
        print("Test_001 setUp")
        Common.selectProduct("ZC201811051102248676274--会员稳盈45天")
        Common.selectTemplate()
        Common.getProducts()
        Common.getProducts(product_type=2)
        Common.getProducts(product_type=15)

        Common.selectProductRate("ZC201810271616327806101")

        #创建计划类产品
        Common.createProduct(product_Type="月增2", tmpId=178, raise_end_time="2018-11-29 23:59:59")
        Common.createProduct(product_Type="周增", tmpId=176, raise_end_time="2018-11-29 23:59:59")
        Common.createProduct(product_Type="双月增", tmpId=177, raise_end_time="2018-11-29 23:59:59")
        Common.createProduct(product_Type="季增", tmpId=175, raise_end_time="2018-11-29 23:59:59")


        #创建定期产品
        Common.createProduct(prodType="dq",tmpId=26,product_term=30, raise_end_time="2018-11-29 23:59:59")
        Common.createProduct(prodType="dq",tmpId=26,product_term=45, raise_end_time="2018-11-29 23:59:59")
        Common.createProduct(prodType="dq",tmpId=476,product_term=180, raise_end_time="2018-11-29 23:59:59")
        Common.createProduct(prodType="dq",tmpId=476,product_term=180, raise_end_time="2018-11-29 23:59:59")
        Common.createProduct(prodType="dq",tmpId=477,product_term=365, raise_end_time="2018-11-29 23:59:59")


        Common.dumpProduct("ZC201810231934317207970")
        Common.loadProduct("ZC201810231704586551135")

        Common.cleanCache("ZC201810271612155392959")
        Common.cleanCache("1100111023")
        Common.cleanCache("1100099819")
        Common.getProducts()
        Common.getProducts(product_type=2)
        Common.getProducts(product_type=15)

        Common.updateProduct("ZC201810271612155392959--月增1",product_name="月增1810271-1")
        Common.updateProduct("PD201811021537011796814--稳盈30天",product_name="稳赢180天2-1811021")
        Common.updateProduct("PD201811021536466705388--稳盈30天",product_name="稳赢180天1-1811021",product_term=45)
        Common.updateProduct("PD201811021537155905329--会员稳盈45天",product_term=365)


    def test(self):
        Common.getRecordProduct(product_type=2)
        Common.getRecordProduct(product_type=15)


        zou_zeng = ["ZC201811021543036535828--周增"]
        # for pno in zou_zeng:
        #     Common.updateProduct(pno, product_status=6, raise_end_time="2018-10-22 19:44:59", )
        #     Common.updateProduct(pno, raise_start_time="2018-11-06 20:45:58")


        yue_zeng = ["ZC201811021542493603457--月增1","ZC201811021544119711209--月增2",]

        # for pno in yue_zeng:
        #     Common.updateProduct(pno, product_status=6, raise_end_time="2018-10-22 19:44:59", )
        #     Common.updateProduct(pno, raise_start_time="2018-11-06 20:45:58")
        #     Common.raiseInterest("ZC201811021544119711209--月增2", interest=0.01)
        #     Common.updateProduct(pno, product_status=5, raise_end_time="2018-10-22 19:44:59", )
        #     Common.raiseInterest("ZC201810271612155392959--月增1",interest=0.01)

        shuang_yue_zeng = ["ZC201811051102248676274--双月增"]

        # for pno in shuang_yue_zeng:
        #     Common.updateProduct(pno, product_status=6, raise_end_time="2018-10-22 19:44:59", )
        #     Common.updateProduct(pno, raise_start_time="2018-11-06 20:45:58")
        #     Common.updateProduct(pno, raise_start_time="2018-10-28 20:45:58")


        ji_zeng = ["ZC201811021543316887880--季增"]
        # for pno in ji_zeng:
        #     Common.updateProduct(pno, product_status=6, raise_end_time="2018-10-22 19:44:59", )
        #     Common.updateProduct(pno,  raise_start_time="2018-11-06 20:45:58")


        # 稳赢 依次是30天 45天 180天 365天
        wen_yin = ["PD201811021211375358704--稳盈30天",
                   "PD201811021225145083623--稳盈45天",
                   "PD201811021536466705388--稳盈180天1"
                   "PD201811021537011796814--稳盈180天2",
                   "PD201811021537155905329---稳盈365天"]

        for pno in zou_zeng+yue_zeng+shuang_yue_zeng+ji_zeng+wen_yin:
            Common.loadProduct(pno)
            Common.updateProduct("PD201811021537011796814", product_status=5,raise_start_time="2018-10-22 19:44:59", )
            Common.dumpProduct(pno)
            Common.updateProduct("PD201811021537155905329", product_status=6,raise_end_time="2018-10-22 19:44:59", )
            Common.selectProduct(pno)

            Common.updateProduct(pno,product_status=5,raise_start_time="2018-10-26 20:45:58",raise_end_time="2018-11-22 19:44:59",)

        Common.raiseInterest("ZC201811021542493603457",last_period=True)

        Common.updateProduct("ZC201811021614205379893", raise_start_time="2018-11-08 20:45:58")
        Common.updateProduct("PD201811021537155905329", product_status=6, raise_end_time="2018-10-22 19:44:59", )

        #保存原来的数据
        for pno in ['ZC201809191703211410036',
         'ZC201809261819559565342', 'ZC201809271627141142166', 'ZC201809271627556400407',
         'ZC201809271628290466117', 'ZC201809271629553471537', 'ZC201809271630345286732', 'ZC201809271632456120154',
         'ZC201809271749128823858', 'ZC201809281347298486231', 'ZC201809281504405179733'] +[
        'PD201809131654007982530', 'PD201809271652376254803', 'PD201809271652596506285', 'PD201809271653221883476',
         'PD201809271653487265011', 'PD201809271654058195756', 'PD201809271655557256670', 'PD201809271656284791774',
         'PD201810091520046189442', 'PD201811021117424414179', 'PD201811021537011796814']:
            # Common.dumpProduct(pno)
            Common.updateProduct(pno, product_status=6, raise_end_time="2018-10-22 19:44:59", )







    def tearDown(self):
        print("Test_001 tearDown")
